<template>
	<!-- ok -->
	<view class="wanlpage-menu grid text-center" :class="'col-' + pageData.params.colfive" :style="[pageData.style]">
		<view class="item" :style="{'margin-top':pageData.params.menuMarginTop}" v-for="(menu, keys) in bannerAD"
			:key="keys" @tap="onLink(keys)">
			<view v-if="pageData.params.menuType === 'icon'" class="picicon" :class="menu.bgClass" :style="{
				'height':pageData.params.menuHeightWidth,
				'width':pageData.params.menuHeightWidth,
				'margin-bottom':pageData.params.menuMarginBottom,
				'border-radius':pageData.params.menuBorderRadius
			}">
				<text :class="[menu.icon,menu.iconClass]" :style="{'font-size':pageData.params.menuIconSize}"></text>
			</view>
			<view v-else  style="margin-top:5px;" class="picicon" :class="menu.bgClass" :style="{
				'margin-bottom':pageData.params.menuMarginBottom
			}">
				<image :src="$wanlshop.oss(menu.icon_path, 100, 0, 1, 'transparent', 'png')" :style="{
					'height':pageData.params.menuHeightWidth,
					'width':pageData.params.menuHeightWidth,
					'border-radius':pageData.params.menuBorderRadius
				}" mode="heightFix"></image>
			</view>
			<view :style="{'font-size':pageData.params.menuTextSize}" style="font-weight:600">
				{{menu.name}}
			</view>
		</view>
	</view>
</template>
<script>
	export default {
		name: "WanlPageMenu",
		props: {
			pageData: {
				type: Object,
				default: function() {
					return {
						"name": "菜单组件",
						"type": "menu",
						"params": {
							"menuType": "image",
							"colfive": "5",
							"menuMarginTop": "2",
							"menuMarginBottom": "2",
							"menuHeightWidth": "110rpx",
							"menuIconSize": "76rpx",
							"menuBorderRadius": "2000rpx",
							"menuTextSize": "24rpx"
						},
						"style": {
							"color": "#333333",
							"margin": "25rpx",
							"margin-bottom": "0rpx",
							"line-height": "1.5"
						},
						data: [
						]
					}
				}
			},
			bannerAD: {
				type: Array,
				default: () => []
			}
		},
		// 1.0.2升级
		methods: {
			async onLink(cur_index) {
				// alert(3)
				uni.setStorageSync('cur_index',cur_index)
				uni.setStorageSync('child_index',-1)
				uni.removeStorage({
				    key: 'cur_id', //key String 本地缓存中的指定的 key
				    success: function (res) { //success Function 接口调用的回调函数
				        console.log('success');
				    }
				});

				// uni.removeStorageSync('cur_id')
				// this.$store.dispatch('category', goods);
				uni.switchTab({
					url: '/pages/category',
				});
			}
		}
	}
</script>
<style>
	.wanlpage-menu .picicon {
		display: inline-flex;
		align-items: center;
		justify-content: center;
	}
</style>